<template>
  <j-modal
    :width="modalWidth"
    :visible="visible"
    :title="title"
    switchFullscreen
    @cancel="close"
    style="top: 50px"
    cancelText="关闭"
  >
    <buss-in-out-detail-list-form ref="realForm" 
    :detailId="detailId"
    :code="code"
    :quantity="quantity"></buss-in-out-detail-list-form>
  </j-modal>
</template>
<script>
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'


import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction, putAction } from '@api/manage'
import { filterMultiDictText } from '@/components/dict/JDictSelectUtil'
import { forEach } from 'min-dash'

import  BussInOutDetailListForm from '@/components/base/modal/BussInOutDetailListForm'

export default {
  name: 'BussInOutDetailListModal',
  mixins: [JeecgListMixin, mixinDevice],
  components: {BussInOutDetailListForm,},
  // props: ['category', "modalWidth",],
  props: {
    category: {
      type: String,
    },
    modalWidth: {
      type: Number,
      required: false,
      default: 1250,
    },
    checkval: {
      type: String,
      default: 'radio',
    },
    supplierId: {
      type: String,
      required: false,
    },
    code: {
      type: String,
    },
    quantity: {
      type: String,
    },
  },
  watch: {
    category(newValue) {
      // 当category变更时，可以进行一些处理
      console.log('Category changed to:', newValue)
      this.queryParam = { id: newValue }
      this.detailId = newValue
    },
        code(newValue) {
      // 当category变更时，可以进行一些处理
      console.log('Category changed to:', newValue)
     this.code = newValue
    },
        quantity(newValue) {
      // 当category变更时，可以进行一些处理
      console.log('Category changed to:', newValue)
      this.quantity = newValue
    },


  },
  data() {
    return {
      description: '库存明细页面',
      circleColors: [],
      detailId:'',
      visible: false,
      title: '库存明细',
      disableMixinCreated: true,
      queryParam: { id: this.category | 1 },
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 },
      },
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '操作人',
          align: 'center',
          dataIndex: 'operator',
        },
        {
          title: '操作时间',
          align: 'center',
          dataIndex: 'operationTime',
        },
        {
          title: '业务',
          align: 'center',
          dataIndex: 'business_dictText',
        },
        {
          title: '业务类型',
          align: 'center',
          dataIndex: 'businessType_dictText',
        },
        {
          title: '数量',
          align: 'center',
          dataIndex: 'quantity',
        },
        // {
        //   title: '单位',
        //   align:"center",
        //   dataIndex: 'meUnit_dictText',
        // },
        {
          title: '条码',
          align: 'center',
          dataIndex: 'barcode',
        },
        {
          title: '业务编号',
          align: 'center',
          dataIndex: 'businessCode',
        },
        {
          title: '备注',
          align: 'center',
          dataIndex: 'remark',
        },
      ],
      url: {
        list: '/inventory/bussInventory/queryBussInventoryInoutDetailsByDetailId',
        delete: '/inventory/bussInventory/delete',
        deleteBatch: '/inventory/bussInventory/deleteBatch',
        exportXlsUrl: '/inventory/bussInventory/exportXls',
        importExcelUrl: 'inventory/bussInventory/importExcel',
      },
      dictOptions: {},
      superFieldList: [],
    }
  },
  created() {
    this.getSuperFieldList()
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    handleSubmit() {
      this.getGoodsSelectRows()
      this.searchReset(false)
      this.onClearSelected()
      this.close()
    },
    add() {
      this.showModal()
    },

    showModal() {
      this.dataSource = []
      this.visible = true
      console.log(this.category)
    },
    getGoodsSelectRows() {
      let selectedRow = null
      if (this.checkval == 'radio') {
        selectedRow = this.selectionRows[0]
      } else {
        selectedRow = this.selectedRowKeys
      }
      // let selectedRow = this.selectionRows[0];
      //传递选中的数据
      this.$emit('inventoryOk', selectedRow)
    },
    initDictConfig() {},
    close() {
      this.searchReset(false)
      this.visible = false
    },
    getSuperFieldList() {
      let fieldList = []
      fieldList.push({ type: 'string', value: 'operator', text: '操作人', dictCode: '' })
      fieldList.push({ type: 'string', value: 'operationTime', text: '操作时间', dictCode: '' })
      fieldList.push({ type: 'string', value: 'business', text: '业务', dictCode: 'kc_business' })
      fieldList.push({ type: 'string', value: 'businessType', text: '业务类型', dictCode: 'kc_business_type' })
      fieldList.push({ type: 'BigDecimal', value: 'quantity', text: '数量', dictCode: '' })
      fieldList.push({ type: 'string', value: 'meUnit', text: '单位', dictCode: 'ji_unit' })
      fieldList.push({ type: 'string', value: 'barcode', text: '条码', dictCode: '' })
      fieldList.push({ type: 'string', value: 'businessCode', text: '业务编号', dictCode: '' })
      fieldList.push({ type: 'string', value: 'remark', text: '备注', dictCode: '' })
      this.superFieldList = fieldList
    },
    
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>